package com.berry.MedCheck;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

/**
 * Created with IntelliJ IDEA.
 * User: Airay.Rong
 * Date: 13-12-5
 * Time: 上午9:57
 * To change this template use File | Settings | File Templates.
 */
public class DialogActivity extends Activity implements View.OnClickListener {
	private TextView mTilte;
	private TextView mMsg;
	private TextView mButton;
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_activity);
		mTilte = (TextView) findViewById(R.id.dialog_title);
		mMsg = (TextView) findViewById(R.id.dialog_message);
		mButton = (TextView) findViewById(R.id.dialog_btn);
		mButton.setOnClickListener(this);
		dealWithIntent(getIntent());
	}

	private void dealWithIntent(Intent intent) {
		if (intent == null) {
			Toast.makeText(this,"Need String intent",Toast.LENGTH_SHORT).show();
			finish();
			return;
		}
		String sMsg = intent.getStringExtra("msg");
		String sTitle = intent.getStringExtra("title");
		mTilte.setText(sTitle);
		mMsg.setText(sMsg);

	}

	@Override
	public void onClick(View v) {
		if (v == mButton) {
			finish();
		}
	}

	@Override
	protected void onPause() {
		super.onPause();
		finish();
	}
}